<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
function ValidateForm(frm)
{
	var page_id = document.getElementById('id').value;

	if(page_id == "") {
		document.getElementById('process').value = 'add';
	}
	else {
		document.getElementById('process').value = 'edit';
	}
	document.frm.submit();
	return false;
}
</script>
<?php
if($_REQUEST['_d'] == "") {
	$text = "Add";
}
else {
	$text = "Edit";
}
$query = mysql_query("select `id`, `page_name`, `ad_name`, `active_status` 
					 from map_ads where id='".$_REQUEST['_d']."'") or die(mysql_error());

$res = mysql_fetch_array($query);

if($res["active_status"] == 0) {
	$deactive_status = "checked";
}
else {
	$active_status = "checked";
}


?>
<table border="0" width="100%" align="center">
<tr>
	<td width="46%" align="left"><span style="color:#1B78B7; font-size:14px; font-weight:bold">
    Map Ads</span>&nbsp; 
	<!--<input type="button" name="addnew" value="Add New" onclick="return show();" />-->
	</td>
	<td width="40%" align="right" class="font12">
    <a href="index.php?tc=map_ads" class="font12"><?php echo $text;?> Map Top Ads</a></td>
</tr>
<tr>
	<td background="images/topline.gif" colspan="3" height="11"></td>
</tr>    
</table>
<form name="formPage" method="post" action="action.php" onSubmit="return ValidateForm(this);">
<table width="99%" align="center" border="0"  class="list">
<tr>
	<td align="right" width="250">Page*</td>
    <td align="left">
    <select name="page_name" id="page_name" style="width:250px;">
    <?php 
	$qry = mysql_query("select id,page_name from page where active_status = '1'") or die(mysql_error());
	while($row=mysql_fetch_array($qry)) {
		if($row['id'] == $res['page_name']) {
			echo '<option value="'.$row['id'].'" selected>'.$row['page_name'].'</option>';
		}
		else {
			echo '<option value="'.$row['id'].'">'.$row['page_name'].'</option>';
		}
	}
	?>
    </select>
    </td>
</tr>
<tr>
	<td align="right" width="250">Ads Name*</td>
    <td align="left">
    <select name="ad_name" id="ad_name" style="width:250px;">
    <?php 
	$qry = mysql_query("select id,ad_name from banner_ads where active_status = '1'") or die(mysql_error());
	while($row=mysql_fetch_array($qry)) {
		if($row['id'] == $res['ad_name']) {
			echo '<option value="'.$row['id'].'" selected>'.$row['ad_name'].'</option>';
		}
		else {
			echo '<option value="'.$row['id'].'">'.$row['ad_name'].'</option>';
		}
		
	}
	?>
    </select>
    </td>
</tr>
<tr>
  <td align="right" width="150">Status :</td>
  <td align="left">
  <input name="authorised" type="radio" value=1 <?php echo $active_status;?> />&nbsp;Active&nbsp;&nbsp;
  <input  name="authorised" type="radio" value=0 <?php echo $deactive_status;?>/>&nbsp;Deactive</td>
</tr>
<tr>
	<td align="right" width="150"></td>
    <td align="left">
    <input name="id" id="id" type="hidden" value="<?php echo $res['id'];?>"/>
    <input name="banner_type" id="banner_type" type="hidden" value="top"/>
    <input name="module" id="module" type="hidden" value="map_ads"/>
    <input name="process" id="process" type="hidden" value=""/>
    <input type="submit" value="Submit" name="save_gadgettech">&nbsp;<input type="reset" name="reset" value="Clear" /></td>
</tr>
</table>
</form>